Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTC-15334: Fix crash caused by a race condition #397

Merged
merged 2 commits into from
Jan 13, 2025
Merged

Conversation

RicardoMDomingues
Copy link
Member

I believe this fix the crash we have seen on compute hmac.

The crash happens to a race condition. STUN packets that are addressed to ProbeServer are being processed on Endpoint jobQueue. If multiple STUN packets arrives in different endpoint (udp ipv4, udp ipv6, tcp ipv4, tcp ipv6) the race can happen on _hmacComputer.

To fix that, ProbeServer now has it's own jobQueue

}
else

if (endpoint.getTransportType() != ice::TransportType::UDP)
Copy link
Member Author

@RicardoMDomingues RicardoMDomingues Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was another bug. If we received something that was not properly authenticated on UdpEndpoint, we would close UdpEndpoint which is shared port 10000

Copy link
Contributor

@reddvl1980 reddvl1980 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@olofkallander olofkallander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I guess this contention on hmac computer becomes more severe with use of ipv6 and higher traffic.
Most of the time a client will not probe at all before call and if it does, it fires at udp ipv4 before it does tcp v4, if at all. Even if multiple clients probe simultaneously they are serialized over the udp endpoint recvjobqueue. But with ipv6 udp there are two parallell paths.

@RicardoMDomingues
Copy link
Member Author

Nice catch. I guess this contention on hmac computer becomes more severe with use of ipv6 and higher traffic. Most of the time a client will not probe at all before call and if it does, it fires at udp ipv4 before it does tcp v4, if at all. Even if multiple clients probe simultaneously they are serialized over the udp endpoint recvjobqueue. But with ipv6 udp there are two parallell paths.

When I was doing this I was thinking in add two (or more) queues with their own hmacComputer instance and use round robin too avoid contention. Decided that probably is not worth, as you said, this is something that clients do once in a while, then there will be not much pressure on this endpoint I believe. And everything gets conteined already by endpoint queues, so don't think this will cause much delays (only when process different endpoints in simultaneous), still the client should use the lowest response time after an X number of stun responses, which hopefully is enough to avoid wrong decision due contention

@RicardoMDomingues RicardoMDomingues merged commit 3386775 into master Jan 13, 2025
10 checks passed
@RicardoMDomingues RicardoMDomingues deleted the RTC-15334 branch January 13, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants